<?php
require_once("init.php");
require_once("inc/header.php");

$q=$_GET['q'];
$page=$_GET['page'];
if(!intval($page)>0) {
    $page=1;
}
$url="http://search.twitter.com/search.json?q=".$q."&page=".$page;
$timeline=obj_to_array(get_from_twitter($url));
$i=0;
foreach($timeline as $msgs) {
    if(gettype($msgs)=="array") {
        foreach($msgs as $msg) {
            $i+=1;
            $msg=obj_to_array($msg);
            show_search_msg($i,$msg,$type,$page);
        }
    }
}
if($page>1) {
    echo "<a href='search.php?q=".$q."&page=".($page-1)."'>prev</a> ";
}
echo "<a href='search.php?q=".$q."&page=".($page+1)."'>next</a> ";
require_once("inc/footer.php");
?>